const headerDl = document.querySelector('.header_dl')
let navFooter = document.querySelector('.nav_footer')

let tokens = JSON.parse(localStorage.getItem('message'))||''
function geTel (tel) {
  let reg = /^(\d{3})\d{4}(\d{4})$/;
  return tel.replace(reg, "$1****$2");
}

if (!tokens.token) { 
  headerDl.addEventListener('click', function (e) {
    console.log(e.target.tagName)
    if (e.target.tagName==='IMG'||e.target.tagName==='P') { 
      location.href='./login.html'
    }
  })
  navFooter.style.opacity=0
}

if (tokens.token) { 
  navFooter.style.opacity=1
  document.querySelector('.wei').innerHTML = geTel(tokens.userPhone)
  document.querySelector('.dian').innerHTML = tokens.userPhone
  document.querySelector('.yue').innerHTML = 66666
  document.querySelector('.jifen').innerHTML = 6666
  document.querySelector('.youhui').innerHTML = `3张`
  navFooter.addEventListener('click',function () {
    localStorage.removeItem('message')
    navFooter.style.opacity = 0
    location.reload(true)
  })
}